package homework.Demo4;

import java.util.*;

public class Test {
    public static void main(String[] args) {
        ArrayList<String> production=new ArrayList<>();
        Scanner sc=new Scanner(System.in);
        System.out.println("请输入商品名称，每行输入一个，以end结束");
        while (true){

            String input=sc.nextLine();
            if(input.equals("end")){
                break;
            }else {
                production.add(input);
            }
        }
        HashMap<String,Integer> map=new HashMap<>();
        for (String s : production) {
            map.put(s, map.getOrDefault(s, 0) + 1);
        }
        Set<String> set = map.keySet();
        for (String s : set) {
            System.out.println(s+"售出数量：" +map.get(s));
        }

    }
}
